package com.training.java.module2;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class FillQuestionsFromFile {

    public FillQuestionsFromFile(){
        BufferedReader bufferedReader;
        try {
            bufferedReader = new BufferedReader(new FileReader("questions.txt"));
            try {
                readFromFile(bufferedReader);
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (FileNotFoundException e) {
            System.out.println("File Not Found");
        }


    }

    private void readFromFile(BufferedReader bufferedReader) throws IOException  {
        String currentLine = bufferedReader.readLine();

        while(currentLine != null) {
            QuestionsCollection.getInstance().addQuestion(currentLine);
            currentLine = bufferedReader.readLine();
        }
    }
}
